<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use common\libs\Constants;

/* @var $this yii\web\View */
/* @var $model backend\models\Order */

$this->title                   = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Orders', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="order-view">

    <h1><?= Html::encode($this->title) ?></h1>

    <?= DetailView::widget([
        'model'      => $model,
        'attributes' => [
            'id',
            'order_id',
            [
                'attribute' => 'uid',
                'value'     => function ($model) {
                    return $model->u->username;
                }
            ],
            [
                'attribute' => 'status',
                'filter'    => Constants::getOrderStatus(),
                'value'     => function ($model) {
                    if (isset($model->status)) {
                        return Constants::getOrderStatus($model->status);
                    }

                    return '-';
                }
            ],
            [
                'attribute' => 'type',
                'filter'    => Constants::getOrderType(),
                'value'     => function ($model) {
                    if (isset($model->type)) {
                        return Constants::getOrderType($model->type);
                    }

                    return '-';
                }
            ],
            'job_id',
            'good_id',
            [
                'label' => '商品名',
                'value' => function ($model) {
                    /**@var \api\models\Order $model */
                    return $model->good->title;
                }
            ],
            [
                'label' => '单价',
                'value' => function ($model) {
                    /**@var \api\models\Order $model */
                    return '¥' . $model->good->price;
                }
            ],
            [
                'label' => '商品权限',
                'value' => function ($model) {
                    /**@var \api\models\Order $model */
                    return $model->good->right0->item_name;
                }
            ],
            'number',
            'total_price',
            'location',
            'notify',
            'created_at:datetime',
            'updated_at:datetime',
        ],
    ]) ?>

</div>
